home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: CTableExpander.c
- * Created: 8/1/93
- * Desc: A mousetask that handles drawing the expando icon.
- *
- * Superclass: CTableDragger.
- * Uses: CItemTable, CItem.
- * Original Author: W. Wesley Monroe
- * Modifications:
- *
- * Copyright © 1993 Animas Software Production. All rights reserved.
- */
-
- #include "CTableExpander.h"
- #include "CItemTable.h"
- #include "CItem.h"
- #include <Icons.h>
-
- enum {
- kArrowCollapsed = 131,
- kArrowTransition,
- kArrowExpanded
- };
-
- #define kCellLevelIndent 16
-
- void CTableExpander::ITableExpander(CTable *aTable, short theModifiers,
- long selFlags, CItem *item, Rect iconR)
- {
- short expanded;
-
- ITableDragger(aTable, theModifiers, selFlags);
-
- fSelItem = item;
-
- ASSERT(item);
- fExpanded = item->GetExpanded();
- fIndentLeft = item->GetLevel()*kCellLevelIndent;
-
- fInTriangle = TRUE;
- fInverted = 0;
- fIconR = iconR;
- fArrowICNid2 = kArrowTransition;
- fArrowICNid1 = fExpanded ? kArrowExpanded : kArrowCollapsed;
- fArrowICNid3 = !fExpanded ? kArrowExpanded : kArrowCollapsed;
- }
-
- void CTableExpander::BeginTracking( LongPt *startPt)
- {
- Rect r;
-
- r = fIconR;
- ((CItemTable *) itsTable)->Draw7Icon(&r, 0, fArrowICNid1,ttSelected);
- }
-
- void CTableExpander::KeepTracking(LongPt *currPt, LongPt *prevPt,
- LongPt *startPt)
- {
- LongRect lr;
- Rect r;
- short inOut;
-
- r = fIconR;
- QDToLongRect(&r, &lr);
- fInTriangle = PtInLongRect(currPt, &lr);
-
- if(fInTriangle == 1 && fInverted == 0) {
-
- fInverted = 1;
- ((CItemTable *) itsTable)->Draw7Icon(&r, 0, fArrowICNid1,ttSelected);
- } else if(fInTriangle == 0 && fInverted == 1) {
-
- fInverted = 0;
- ((CItemTable *) itsTable)->Draw7Icon(&r, 0, fArrowICNid1,ttNone);
- }
- }
-
- /*
- * EndTracking()
- *
- * If released in the expando icon,
- * - Animate the expando icon,
- * - Send the setexpand message to the hitCell,
- * - Send the expandCell message to the hitCell.
- * else
- * - just redraw the icon.
- */
-
- void CTableExpander::EndTracking(LongPt *currPt, LongPt *prevPt,
- LongPt *startPt)
- {
- CItem *aItem = fSelItem;
- Cell hitCell;
- Rect iconRect;
-
- iconRect = fIconR;
- itsTable->FindHitCell(startPt, &hitCell);
-
- if(fInTriangle == 1) {
-
- long ts;
-
- ((CItemTable *) itsTable)->DrawTriangle(&iconRect, 0, fArrowICNid1);
- ts = TickCount();
- while(ts + 5 > TickCount());
- ((CItemTable *) itsTable)->DrawTriangle(&iconRect, 0, fArrowICNid2);
- ts = TickCount();
- while(ts + 5 > TickCount());
- ((CItemTable *) itsTable)->DrawTriangle(&iconRect, 0, fArrowICNid3);
- fExpanded = !fExpanded;
-
- aItem->SetExpanded(fExpanded);
- ((CItemTable *) itsTable)->ExpandCell(hitCell, fExpanded);
-
- }
- else
- ((CItemTable *) itsTable)->DrawTriangle(&iconRect,
- 0, fArrowICNid1);
-
- }